import {get,post} from '../../utils/request'
const state={
  //用来保存查询出来的轮播信息
  shufflings:[],
  total:0
}

const actions={
  //查询所有轮播信息
  findAllShuffling(context,list){
    //异步操作
    get('/carousel/findAll',list).then(res=>{
      let response=res.data.list
      context.commit('setShufflings',response)
      let total=res.data.total
      context.commit('setTotal',total)
    })
  },

  //保存轮播信息
  saveShuffling(context,list){       
    let respone=post('/carousel/saveOrUpdate',list)
    return respone
  },

  //删除轮播信息
  deleteShuffling(context,list){
    let respone=get('/carousel/deleteById',list)
    return respone
  }
}

const mutations={
  //修改state中的值
  setShufflings(state,response){
    state.categorys=response
  },
  setTotal(state,total){
    state.total=total
  }
}

export default{
  namespaced:true,
  state,
  actions,
  mutations
}